package com.gec.it.controller;


import com.gec.it.entity.Jobs;
import com.gec.it.service.JobsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 雄哥爱吃肉
 * @since 2022-01-04
 */
@Controller
@RequestMapping("/jobs")
public class JobsController {
    @Autowired
    private JobsService service;

    @RequiresPermissions("job:add")
    @GetMapping("/add")
    public String add(){
        return "job_add";
    }
    @PostMapping("/add")
    public String add(Jobs j){
        service.save(j);
        return "redirect:index";
    }
    @RequiresPermissions("job:list")
    @GetMapping("/list")
    public String list(Model m){
        List<Jobs> list =service.list();
        m.addAttribute("list",list);
        return "job_list";
    }
}
